// 竖柱状图
import i18n from '@/lang'
export default {
  initOptions: {
    color: ['#3398DB'],
    tooltip: {
      trigger: 'axis',
      axisPointer: { // 坐标轴指示器，坐标轴触发有效
        type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
      }
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '1%',
      top: '20',
      containLabel: true
    },
    xAxis: [
      {
        type: 'category',
        data: [],
        axisTick: {
          alignWithLabel: true
        },
        axisLine: {
          lineStyle: { color: '#ffffff' }
        },
        axisLabel: {
          interval: 0,
          rotate: -70,
          formatter (value) {
            return value.length > 8 ? value.substring(0, 8) + '...' : value
          }
        }
      }
    ],
    yAxis: [
      {
        type: 'value',
        axisLine: {
          lineStyle: { color: '#ffffff' }
        }
      }
    ],
    series: [
      {
        name: '',
        type: 'bar',
        barWidth: '60%',
        data: []
      }
    ]

  },
  setEchart (echartObject, Xdata, Ydata) {
    echartObject.setOption(this.initOptions)
    echartObject.setOption({
      xAxis: [{
        data: Xdata
      }],
      series: [{
        name: i18n.t('vehicleNumber'),
        data: Ydata
      }]
    })
    setTimeout(() => {
      echartObject.resize()
    })
  }
}
